layui.use(["jquery","element","layer"],function () {
    var $ = layui.jquery;
    var layer = layui.layer;

    //向下箭头的鼠标移入移出事件
    $("#down").mouseenter(function () {
        $("#down").css("color","#1E9FFF");
    });
    $("#down").mouseleave(function () {
        $("#down").css("color","white");
    });

    //向下箭头滚动页面
    $("#down").click(function () {
        $('html,body').animate({ scrollTop: document.getElementById("black_bg").scrollHeight}, 1000); return false;
    });

    //文章图片鼠标上移效果
    var article_imgs = $(".article_img");
    var img_shows = $(".img_show");
    $.each(article_imgs, function (index,item) {
        $(item).mouseenter(function () {
            $(img_shows[index]).stop().animate({
                width:$(".article_img").width(),
                height:$(".article_img").height(),
            },500)
        });
    });
    $.each(article_imgs, function (index,item) {
        $(item).mouseleave(function () {
            $(img_shows[index]).stop().animate({
                width:0,
                height:0,
            },500)
        });
    });

    //控制显示返回顶部按钮
    $(window).scroll(function () {
        if ($(document).scrollTop() >= 150){
            $("#to_top").show();
        }else{
            $("#to_top").hide();
        }
    });
    //返回顶部点击事件
    $("#to_top").click(function () {
        $("html,body").animate({
            scrollTop:0
        },1000);
    });

    //控制微信二维码弹出层
    $("#wechat").click(function () {
        layer.open({
            type:1,
            title:"WeChat",
            content: $('#wechatimg'),
            area: ['300px', '344px']
        })
    });


    //设置页面加载从接口动态获取句子
    $(function () {
        $.ajax({
            url:"https://v1.hitokoto.cn",
            type:"get",
            data:{c:"d"},
            success:function (data) {
                var from = data.from_who;
                if (from == null || from == "null"){
                    from = data.from;
                }
                var phrase = data.hitokoto;
                $("#phrase").append(phrase);
                $("#from").append(from);
            }
        })
    });
});

//网站运行时间，一秒刷新
$(function () {
    setInterval("time()",1000);
});